package com.yn.pet.controller.app;

import com.yn.common.core.domain.AjaxResult;
import com.yn.pet.controller.app.biz.AHelpCenterBizService;
import com.yn.pet.controller.pc.response.HelpCenterDetailResponse;
import com.yn.pet.controller.pc.response.page.HelpCenterPageResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

@RestController
@AllArgsConstructor
@RequestMapping("/front/helpCenter")
@Api(tags = "app端——帮助中心Controller")
@Slf4j
public class AHelpCenterController {
    private final AHelpCenterBizService aHelpCenterBizService;


    /**
     * 用户端分页查询帮助中心
     * @param pageNum 当前页
     * @param pageSize 每页显示数量
     * @param noticeType 通知类型: 3-功能介绍, 4-常见问题
     * @return
     */
    @GetMapping("/common/pageList")
    @ApiOperation("用户端分页查询帮助中心")
    public AjaxResult pageList(@RequestParam(required = false,defaultValue = "1") Integer pageNum,
                               @RequestParam(required = false,defaultValue = "10") Integer pageSize,
                               @ApiParam(value = "通知类型: 3-功能介绍, 4-常见问题", allowableValues = "3,4", required = true)
                               @RequestParam(required = true) @NotNull Integer noticeType) {
        log.info("用户端分页查询帮助中心常用问题入参：currentPage:{},pageSize:{},noticeType:{}",pageNum,pageSize,noticeType);
        HelpCenterPageResponse pageResponse = aHelpCenterBizService.pageList(pageNum, pageSize, noticeType);
        return AjaxResult.success(pageResponse);
    }

    /**
     * 用户端分页查询帮助中心常用问题详情
     * @param noticeId 公告ID
     * @return
     */
    @GetMapping("/common/detail/{noticeId}")
    @ApiOperation("查询帮助中心信息详情")
    public AjaxResult queryNoticeTypeByDictType(@PathVariable @NotNull @ApiParam(value = "公告ID") Long noticeId) {
        log.info("用户端查询帮助中心的常见问题入参：noticeId:{}",noticeId);
        HelpCenterDetailResponse response = aHelpCenterBizService.queryDetail(noticeId);
        return AjaxResult.success(response);
    }

    /**
     * 查询字典数据
     * @param dictType 字典类型
     * @return 字典数据
     */
    @GetMapping("queryMapByDictType")
    @ApiOperation("查询字典数据")
    public AjaxResult queryMapByDictType(@ApiParam(value = "字典类型", required = true) @RequestParam(required = true) @NotBlank String dictType) {
        log.info("查询字典数据入参：dictType:{}",dictType);
        return AjaxResult.success(aHelpCenterBizService.queryNoticeTypeByDictType(dictType));
    }




}
